package org.nanotek.lucene.job.readers;

import java.util.List;

import org.nanotek.Base;
import org.nanotek.beans.ArtistKey;
import org.nanotek.dao.spring.ArtistDAO;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;

public class ArtistKeyDAOReader implements IArtistKeyDAOReader{

	private Integer startRecord = 0; 
	private Integer maxResults = 0; 
	private ArtistDAO<ArtistKey> artistDAO; 
	
	@Override
	public List<Base<?>> read() throws Exception, UnexpectedInputException,
			ParseException, NonTransientResourceException {
		 List<Base<?>> artists = artistDAO.listRecords(startRecord, maxResults);
		return (artists.size()>0)?artists:null;
	}

	public Integer getStartRecord() {
		return startRecord;
	}

	/* (non-Javadoc)
	 * @see org.nanotek.lucene.job.readers.IArtistKeyReader#setStartIndex(java.lang.Integer)
	 */
	@Override
	public void setStartRecord(Integer startIndex) {
		this.startRecord = startIndex;
	}

	public Integer getMaxResults() {
		return maxResults;
	}

	/* (non-Javadoc)
	 * @see org.nanotek.lucene.job.readers.IArtistKeyReader#setMaxResults(java.lang.Integer)
	 */
	@Override
	public void setMaxResults(Integer maxResults) {
		this.maxResults = maxResults;
	}

	public ArtistDAO<ArtistKey> getArtistDAO() {
		return artistDAO;
	}

	public void setArtistDAO(ArtistDAO<ArtistKey> artistDAO) {
		this.artistDAO = artistDAO;
	}

}
